<script setup>
import { ref, onMounted } from 'vue'
import Player from 'xgplayer'
import Mp4Plugin from 'xgplayer-mp4'

// https://edu.citicsf.com/invest-edu/avs/2022/11/8afbdce7442340c8bf342d1ebb1b3af4.mp4
onMounted(() => {
  let player = new Player({
    id: 'mse',
    url: 'http://127.0.0.1:9088/v1/media/video/files/LC.mp4',
    playbackRate: [0.5, 0.75, 1, 1.5, 2], //传入倍速可选数组
    marginControls: true,
    plugins: [Mp4Plugin],
    mp4plugin: {
      maxBufferLength: 30,
      minBufferLength: 10,
      reqOptions: {
        mode: 'cors',
        method: 'POST',
        // 需要带的自定义请求头
        headers: {
          'x-test-header': 'rrrr'
        }
      }
    }
  })
})
</script>
<template>
  <div>
    <div id="mse" style="width: 200px; height: 200px"></div>
  </div>
</template>
<style scoped lang="less"></style>
